let userList = [],
    routerList = [
        // 后台设置
        {
            "name": "System",
            "path": "/system",
            "hidden": false,
            "redirect": "noRedirect",
            "component": "Layout",
            "alwaysShow": true,
            "meta": {
                "title": "后台设置",
                "icon": "icon-menu-setting",
                "noCache": false,
                "link": null
            },
            "children": [{
                    "name": "User",
                    "path": "user",
                    "hidden": false,
                    "component": "system/user/index",
                    "meta": {
                        "title": "用户设置",
                        "icon": "",
                        "noCache": false,
                        "link": null
                    }
                },
                {
                    "name": "Menu",
                    "path": "menu",
                    "hidden": false,
                    "component": "system/menu/index",
                    "meta": {
                        "title": "菜单管理",
                        "icon": "",
                        "noCache": false,
                        "link": null
                    }
                },
                {
                    "name": "Auth",
                    "path": "auth",
                    "hidden": false,
                    "component": "system/auth/index",
                    "meta": {
                        "title": "权限管理",
                        "icon": "",
                        "noCache": false,
                        "link": null
                    }
                },
                {
                    "name": "Dict",
                    "path": "dict",
                    "hidden": false,
                    "component": "system/dict/index",
                    "meta": {
                        "title": "字典管理",
                        "icon": "",
                        "noCache": false,
                        "link": null
                    }
                }, {
                    name: "log",
                    "path": "log",
                    "hidden": false,
                    "component": "system/log/index",
                    "meta": {
                        "title": "操作日志",
                        "icon": "",
                        "noCache": false,
                        "link": null
                    }
                }
            ]
        }
], vipList = [], menuList = [
{
            title: "后台设置",
            name: "System",
            icon: "icon-menu-setting",
            pid: 0,
            sort: 1,
            id: 2,
            path: "/system",
            menuComponent: "Layout",
            child: [{
                    title: "用户设置",
                    name: "User",
                    icon: "",
                    id: 21,
                    pid: 2,
                    sort: 0,
                    path: "/system/user",
                    menuComponent: "Layout",
                },
                {
                    title: "菜单管理",
                    name: "Menu",
                    icon: "",
                    id: 23,
                    pid: 2,
                    sort: 2,
                    path: "/system/menu",
                    menuComponent: "Layout",
                },
            ]
        },
    ],
    dict = []
export default [
    // 用户登录
    {
        url: '/api/login',
        method: 'post',
        response: ({
            body
        }) => {
            const {
                userNumber,
                userPassword
            } = body;
            if (userNumber === 'admin' && userPassword === '123456') {
                return {
                    code: 200,
                    message: '登录成功',
                    data: {
                        token: 'token' + Math.random()
                    }
                }
            } else {
                return {
                    code: 402,
                    message: '用户名或密码错误'
                }
            }
        }
    },
    // 退出
    {
        url: '/api/logout',
        method: 'post',
        response: () => {
            return {
                code: 200,
                message: '退出成功'
            }
        }
    },
    // 获取用户信息
    {
        url: '/api/userInfo',
        method: 'get',
        response: () => {
            return {
                code: 200,
                message: '获取成功',
                data: {
                    name: '火鸡味锅巴',
                    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
                    email: '110@qq.com',
                    phone: '13000000000',
                    address: '山西省长治市潞州区',
                }
            }
        }
    },
    // 获取菜单信息
    {
        url: '/api/menu',
        method: 'get',
        response: () => {
            return {
                code: 200,
                message: '获取成功',
                data: routerList
            }
        }
    },
    // 上传接口
    {
        url: '/api/upload',
        method: 'post',
        headers: {
            'Content-Type': 'application/json',
            'abcd': '123456'
        },
        response: (data) => {
            return {
                code: 200,
                message: '上传成功',
                data: {
                    url: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif'
                }
            }
        }
    },
    // 用户管理列表
    {
        url: '/api/system/user/list',
        method: 'get',
        response: ({
            query
        }) => {
            let arr = [{
                id: 1,
                username: 'admin',
                password: '123456',
                phone: '13000000000',
                avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
                dept: "0",
                remark: "管理员只能一个"
            }, {
                id: 2,
                username: 'admin2',
                password: '123456',
                phone: '13000000000',
                avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
                dept: "2",
                remark: "管理员只能一个"
            }, ]
            userList = userList.concat(arr);
            let obj = {};
            let peon = userList.reduce((cur, next) => {
                obj[next.id] ? "" : obj[next.id] = true && cur.push(next);
                return cur;
            }, [])
            return {
                code: 200,
                message: '获取成功',
                data: {
                    total: peon.length,
                    current: query.current,
                    size: query.size,
                    list: peon
                }
            }
        }
    },
    // 用户管理添加
    {
        url: '/api/system/user/add',
        method: 'post',
        response: ({
            body
        }) => {
            userList.push({
                ...body,
                avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
                id: userList.length + 1
            });
            return {
                code: 200,
                message: '添加成功',
                data: {
                    id: 3,
                }
            }
        }
    },
    // 用户管理编辑
    {
        url: '/api/system/user/edit',
        method: 'put',
        response: ({
            body
        }) => {
            const res = body;
            userList.forEach((item, index) => {
                if (item.id === res.id) {
                    userList[index] = res;
                }
            });
            return {
                code: 200,
                message: '编辑成功',
                data: null
            }
        }
    },
    // 用户管理删除
    {
        url: '/api/system/user/delete',
        method: 'delete',
        response: ({
            body
        }) => {
            userList = userList.filter(item => !body.ids.includes(item.id));
            return {
                code: 200,
                message: '删除成功',
                data: null
            }
        }
    },
    // 菜单管理列表
    {
        url: '/api/system/menu/list',
        method: 'get',
        response: () => {
            return {
                code: 200,
                message: '获取成功',
                data: {
                    list: menuList
                }
            }
        }
    },
    // 菜单管理添加
    {
        url: '/api/system/menu/add',
        method: 'post',
        response: ({
            body
        }) => {
            if (!body.pid) {
                menuList.push({
                    ...body,
                    child: [],
                    id: menuList.length + 1
                });
            } else {
                let pid = body.pid;
                let index = menuList.findIndex(item => item.id === pid);
                if (index !== -1) {
                    menuList[index].child.push({
                        ...body,
                        id: String(menuList[index].id) + menuList[index].child.length + 1
                    });
                }
            }
            return {
                code: 200,
                message: '添加成功',
                data: null
            }
        }
    },
    // 菜单管理编辑
    {
        url: '/api/system/menu/edit',
        method: 'put',
        response: ({
            body
        }) => {
            if (!body.pid) {
                menuList.forEach((item, index) => {
                    if (item.id === body.id) {
                        menuList[index] = body;
                    }
                });
            } else {
                let pid = body.pid;
                let index = menuList.findIndex(item => item.id === pid);
                if (index !== -1) {
                    menuList[index].child.forEach((item, i) => {
                        if (item.id === body.id) {
                            menuList[index].child[i] = body;
                        }
                    });
                }
            }
            return {
                code: 200,
                message: '编辑成功',
                data: null
            }
        }
    },
    // 菜单管理删除
    {
        url: '/api/system/menu/delete',
        method: 'delete',
        response: ({
            body
        }) => {
            menuList = menuList.filter(item => !body.ids.includes(item.id));
            return {
                code: 200,
                message: '删除成功',
                data: null
            }
        }
    },
    // 字典管理列表
    {
        url: '/api/system/dict/list',
        method: 'get',
        response: () => {
            return {
                code: 200,
                message: '获取成功',
                data: {
                    list: dict
                }
            }
        }
    },
    // 字典管理添加
    {
        url: '/api/system/dict/add',
        method: 'post',
        response: ({
            body
        }) => {
            if (!body.pid) {
                dict.push({
                    ...body,
                    child: [],
                    id: dict.length + 1
                });
            } else {
                let pid = body.pid;
                let index = dict.findIndex(item => item.id === pid);
                if (index !== -1) {
                    dict[index].child.push({
                        ...body,
                        id: String(dict[index].id) + dict[index].child.length + 1
                    });
                }
            }
            return {
                code: 200,
                message: '添加成功',
                data: null
            }
        }
    },
    // 字典管理编辑
    {
        url: '/api/system/dict/edit',
        method: 'put',
        response: ({
            body
        }) => {
            if (!body.pid) {
                dict.forEach((item, index) => {
                    if (item.id === body.id) {
                        dict[index] = body;
                    }
                });
            } else {
                let pid = body.pid;
                let index = dict.findIndex(item => item.id === pid);
                if (index !== -1) {
                    dict[index].child.forEach((item, i) => {
                        if (item.id === body.id) {
                            dict[index].child[i] = body;
                        }
                    });
                }
            }
            return {
                code: 200,
                message: '编辑成功',
                data: null
            }
        }
    },
    // 字典管理删除
    {
        url: '/api/system/dict/delete',
        method: 'delete',
        response: ({
            body
        }) => {
            dict = dict.filter(item => !body.ids.includes(item.id));
            return {
                code: 200,
                message: '删除成功',
                data: null
            }
        }
    },
    // 日志列表
    {
        url: '/api/system/log/list',
        method: 'get',
        response: ({
            query
        }) => {
            let logList = [{
                actionTime: "2024-10-01 16:36:13",
                actionUser: "admin",
                actionContent: "新增用户：admin2"
            }, {
                actionTime: "2024-10-12 16:40:13",
                actionUser: "admin",
                actionContent: "新增管理员"
            }, {
                actionTime: "2024-10-10 14:00:00",
                actionUser: "admin",
                actionContent: "导出全部用户信息"
            }, {
                actionTime: "2024-10-10 16:00:13",
                actionUser: "admin",
                actionContent: "发表了动态"
            }, {
                actionTime: "2024-10-01 08:36:13",
                actionUser: "admin",
                actionContent: "删除了字典类型"
            }, {
                actionTime: "2024-10-20 14:36:13",
                actionUser: "admin",
                actionContent: "新建了角色：超级管理员"
            }, {
                actionTime: "2024-11-01 09:36:13",
                actionUser: "admin",
                actionContent: "给admin2授权"
            }, {
                actionTime: "2024-10-15 16:36:13",
                actionUser: "admin",
                actionContent: "导出全部用户信息"
            }, {
                actionTime: "2024-10-22 16:36:13",
                actionUser: "admin",
                actionContent: "新增用户"
            }, {
                actionTime: "2024-10-23 16:36:13",
                actionUser: "admin",
                actionContent: "导出全部用户信息"
            }, {
                actionTime: "2024-10-31 16:36:13",
                actionUser: "admin",
                actionContent: "代码生成"
            }, {
                actionTime: "2024-10-08 16:36:13",
                actionUser: "jacker",
                actionContent: "测试信息"
            }, {
                actionTime: "2024-08-01 16:36:13",
                actionUser: "vince",
                actionContent: "新建路由"
            }]
            const {
                startTime,
                endTime,
                actionUser
            } = query;
            if (startTime && endTime) {
                logList = logList.filter(item => new Date(item.actionTime) >= new Date(startTime) && new Date(item.actionTime) <= new Date(endTime));
            }
            if (actionUser) {
                logList = logList.filter(item => item.actionUser.includes(actionUser));
            }
            return {
                code: 200,
                message: '获取成功',
                data: {
                    total: logList.length,
                    current: query.current,
                    size: query.size,
                    list: logList
                }
            }
        }
    },
]